package com.zzk.protect.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzk.protect.pojo.ConstantType;
import com.zzk.protect.service.ConstantTypeService;
import com.zzk.protect.mapper.ConstantTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 周振坤
* @description 针对表【constant_type】的数据库操作Service实现
* @createDate 2025-06-25 17:43:31
*/
@Service
public class ConstantTypeServiceImpl extends ServiceImpl<ConstantTypeMapper, ConstantType>
    implements ConstantTypeService{
    @Autowired
    private ConstantTypeMapper constantTypeMapper;

    @Override
    public List<ConstantType> selectByIdOrName(Object param) {
        QueryWrapper<ConstantType> wrapper = new QueryWrapper<>();

        if (param instanceof Integer) {
            wrapper.eq("id", param);
        } else if (param instanceof String) {
            wrapper.like("name", param);
        } else {
            throw new IllegalArgumentException("参数类型必须是Long或String");
        }

        return constantTypeMapper.selectList(wrapper);
    }
}




